package com.bobo.rbac.auth.utils;


import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @description: 统一结果返回值
 * @author: BOBO
 * @time: 2022/7/23 15:53
 */

@Data
@AllArgsConstructor
@NoArgsConstructor
public class ResponseResult {
    /**
     * 状态码
     */
    private Integer code;
    /**
     * 提示信息，如果有错误时，前端可以获取该字段进行提示
     */
    private String msg;
    /**
     * 查询到的结果数据，
     */
    private Object data;


    public ResponseResult(Integer code, String msg) {
        this.code = code;
        this.msg = msg;
    }
    /**
     * 成功
     * @param data
     * @return
     */
    public static ResponseResult ok(Object data) {
        return new ResponseResult(200, "成功", data);
    }
    public static ResponseResult ok() {
        return new ResponseResult(200, "成功");
    }

    /**
     * 失败
     * @param code
     * @param msg
     * @return
     */

    public static ResponseResult fail(Integer code, String msg) {
        return new ResponseResult(code, msg);
    }

}
